<?php
/**
 * @package		Joomla.Site
 * @subpackage	com_users
 * @copyright	Copyright (C) 2005 - 2012 Open Source Matters, Inc. All rights reserved.
 * @license		GNU General Public License version 2 or later; see LICENSE.txt
 * @since		1.5
 */

defined('_JEXEC') or die;
JHtml::_('behavior.keepalive');
$btnfg =  JRequest::getVar( 'btnfg','','get' );  
if($btnfg==1) {
	?>
    <script type="text/javascript">
    $(document).ready(function($) {
		$("#btnfg").click();
	});
	</script>
    <?php
}
?>
<div class="inner clearfix">
                        	<!--Login Form-->
                        	<div class="content-decoration w975 h638 bor-std" style="background: url('templates/3dmaler/img/main-img-bg.jpg') no-repeat scroll right bottom #FFFFFF;">
                                <div class="content-view fll" id="login">
                                    <h1>Log på</h1>
                                    <div class="login-ctn">
                                    	<form action="<?php echo JRoute::_('index.php?option=com_users&task=user.login'); ?>" method="post" id="loginForm" name="loginForm">
                                        	<fieldset>                                            
                                            <?php foreach ($this->form->getFieldset('credentials') as $field): ?>
													<?php if (!$field->hidden): ?>
                                                    <?php echo $field->label; ?>
                                                    <?php echo $field->input; ?>
                                                    <?php endif; ?>
                                                <?php endforeach; ?>
                                                <input type="hidden" name="return" value="<?php echo base64_encode($this->params->get('login_redirect_url', $this->form->getValue('return'))); ?>" />
                                                <?php echo JHtml::_('form.token'); ?>
                                            
                                                <label class="check-box">
                                                
                                                <input id="modlgn-remember" type="checkbox" name="remember" class="inputbox" value="yes"/>Husk min e-mail-adresse<br />
                                                <a href="#TB_inline?height=180&amp;width=380&amp;inlineId=resetPassword" id="btnfg" class="thickbox">
                                                • Har du glemt din adgangskode?</a>
                                                </label>
                                                
                                                <p>
                                                    <a href="index.php?option=com_jobs">• Opret maleropgave</a>
                                                    <a href="index.php?option=com_users&view=registration">• Tilmeld malerfirma</a>
                                                </p>
                                                <div class="form-submit">
                                                    <input type="submit" onclick="$('#loginForm').submit();"  value="Log på" class="button fll">
                                                </div>
                                                <a href="index.php" class="fll back">TILBAGE TIL FORSIDEN</a>
                                            </fieldset>
                                        </form>
                                        
                                        <div style="display:none" id="resetPassword">
                                            
                                        <h2 class="blue-txt" style="font-size:17px;">Nulstille adgangskoden</h2><div style="padding-left: 20px;">
                                            	<p>Indtast venligst din email-adresse som bruges til din konto til at hente dit kodeord</p>
                                            	
                                            	
                                            	<p class="input-set">
                                                	<div  id="text_reset_pass"></div>
                                                	<label style="width: 85px;">Din email:</label>
                                                	<input type="text" value="" class="input-txt" style="width: 265px;" id="email">
                                                </p>
                                                <!--
                                                <p class="input-set">
                                                	<div  id="text_reset_pass"></div>
                                                	<label style="width: 85px;">Adgangskode:</label>
                                                	<input type="text" value="" class="input-txt" style="width: 265px;" id="passw">
                                                </p>
                                                -->
                                                <div class="form-submit padt15">
                                                    <input type="button" value="Annuller" class="button reset-btn flr" id="reset">
                                                    <input type="button" value="Send" alt="" class="button send-btn  flr" id="send">
                                                </div> 
                                            </div></div>
                                    </div>
                                </div>
                             </div>
                            <!--/Login Form-->
                        </div>    
<?php                        	       
$input_username = JText::_( 'Indtast din e-mail-adresse' );
$input_password = JText::_( 'Indtast din adgangskode' );
	
?>                        
 <script type="text/javascript">                   
$(document).ready(function($) {
						   
	$('#send').click(function (e){

		//alert('ddd');	
		email=$('#email').val();
		//passw=$('#passw').val();
		jQuery.ajax({
		type: "POST",
		//url: "index.php?option=com_users&view=reset&layout=ajax&email=" +email + "&passw=" +passw,
		url: "index.php?option=com_users&view=reset&layout=ajax&email=" +email ,
		
		dataType: "html",
		success: function(msg){
			
			
				jQuery('#text_reset_pass').html(msg);
				
			
		}
		
	});

	});	

	$('#reset').click(function (e){

		$('#email').attr('value','');
		$('#email').focus();
		

	});		   
		/*					   
	   $("#submitbtn").click(function() {
			  if(jQuery("#opretOpgavebeskrivelseForm").valid())
			  {
	  			   alert('valit');				   
			  }
			  
		});
	  */ 
	   $.validator.addMethod('postalcode', function (value) { 
		if(value=='') return true;	
		return /^\d{4}$/.test(value); 
	   }, '');
		
		if( $('#system-message dd ul li').length > 0) {
			$('#msgbox').html($('#system-message dd ul li').html());
			$('.btnhidden').click();
		}
		$("#loginForm").validate(
			{
				errorPlacement: function(error, element) {			
			},
			invalidHandler: function(form, validator) {
			  var errors = validator.numberOfInvalids();
			if (errors) {
                //$('#alert').html(validator['errorList'][0]['message']);
				$('#msgbox').html(validator['errorList'][0]['message']);
    			$('.btnhidden').click();
            	$('#f_focus').html(validator['errorList'][0]['element'].name);
				validator['errorList'][0]['element'].focus();
				$('#TB_overlay').attr("onclick","close_popup();");
				$('#TB_closeWindowButton').attr("onclick","close_popup();");
				
			  } else {
			  }
			},
			rules: {
                username : "required",				
				password : "required",
				
				
			},
			messages: {
                username: "<?php echo $input_username; ?>",
				password: "<?php echo $input_password; ?>"
				
			}
		});
        close_popup=function(){		
		
    		var fel=$('#f_focus').html();            
    		$('#' + fel ).focus();			
      };
      reset_form=function(){
            document.forms[0].reset()
      };
      
	});
</script>
<input class="btnhidden thickbox flr" alt="#TB_inline?height=auto&width=300&inlineId=tilmeldConfirm" type="hidden" value="Godkend" />
<div id="tilmeldConfirm" style="display:none;">
	<div class="content-view">
        <span id="f_focus" style="display:none;"></span>
        <h2 class="blue-txt center"></h2>
        <p class="message" id="msgbox"></p>
    </div>
</div>                         
                        
                        
                        
<?php return;?>


<div class="login<?php echo $this->pageclass_sfx?>">
	<?php if ($this->params->get('show_page_heading')) : ?>
	<h1>
		<?php echo $this->escape($this->params->get('page_heading')); ?>
	</h1>
	<?php endif; ?>

	<?php if (($this->params->get('logindescription_show') == 1 && str_replace(' ', '', $this->params->get('login_description')) != '') || $this->params->get('login_image') != '') : ?>
	<div class="login-description">
	<?php endif ; ?>

		<?php if($this->params->get('logindescription_show') == 1) : ?>
			<?php echo $this->params->get('login_description'); ?>
		<?php endif; ?>

		<?php if (($this->params->get('login_image')!='')) :?>
			<img src="<?php echo $this->escape($this->params->get('login_image')); ?>" class="login-image" alt="<?php echo JTEXT::_('COM_USER_LOGIN_IMAGE_ALT')?>"/>
		<?php endif; ?>

	<?php if (($this->params->get('logindescription_show') == 1 && str_replace(' ', '', $this->params->get('login_description')) != '') || $this->params->get('login_image') != '') : ?>
	</div>
	<?php endif ; ?>

	<form action="<?php echo JRoute::_('index.php?option=com_users&task=user.login'); ?>" method="post">

		<fieldset>
			<?php foreach ($this->form->getFieldset('credentials') as $field): ?>
				<?php if (!$field->hidden): ?>
					<div class="login-fields"><?php echo $field->label; ?>
					<?php echo $field->input; ?></div>
				<?php endif; ?>
			<?php endforeach; ?>
			<button type="submit" class="button"><?php echo JText::_('JLOGIN'); ?></button>
			<input type="hidden" name="return" value="<?php echo base64_encode($this->params->get('login_redirect_url', $this->form->getValue('return'))); ?>" />
			<?php echo JHtml::_('form.token'); ?>
		</fieldset>
	</form>
</div>
<div>
	<ul>
		<li>
			<a href="<?php echo JRoute::_('index.php?option=com_users&view=reset'); ?>">
			<?php echo JText::_('COM_USERS_LOGIN_RESET'); ?></a>
		</li>
		<li>
			<a href="<?php echo JRoute::_('index.php?option=com_users&view=remind'); ?>">
			<?php echo JText::_('COM_USERS_LOGIN_REMIND'); ?></a>
		</li>
		<?php
		$usersConfig = JComponentHelper::getParams('com_users');
		if ($usersConfig->get('allowUserRegistration')) : ?>
		<li>
			<a href="<?php echo JRoute::_('index.php?option=com_users&view=registration'); ?>">
				<?php echo JText::_('COM_USERS_LOGIN_REGISTER'); ?></a>
		</li>
		<?php endif; ?>
	</ul>
</div>
